/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Silvia
 */
@Entity
@Table(name = "animaltype")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AnimalType.findAll", query = "SELECT a FROM AnimalType a"),
    @NamedQuery(name = "AnimalType.findByIdAnimalType", query = "SELECT a FROM AnimalType a WHERE a.idAnimalType = :idAnimalType"),
    @NamedQuery(name = "AnimalType.findByTypeName", query = "SELECT a FROM AnimalType a WHERE a.typeName = :typeName")})
public class AnimalType implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idAnimalType")
    private Integer idAnimalType;
    @Size(max = 45)
    @Column(name = "typeName")
    private String typeName;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "animalTypeidAnimalType")
    private Collection<Animal> animalCollection;

    public AnimalType() {
    }

    public AnimalType(Integer idAnimalType) {
        this.idAnimalType = idAnimalType;
    }

    public Integer getIdAnimalType() {
        return idAnimalType;
    }

    public void setIdAnimalType(Integer idAnimalType) {
        this.idAnimalType = idAnimalType;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    @XmlTransient
    public Collection<Animal> getAnimalCollection() {
        return animalCollection;
    }

    public void setAnimalCollection(Collection<Animal> animalCollection) {
        this.animalCollection = animalCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idAnimalType != null ? idAnimalType.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AnimalType)) {
            return false;
        }
        AnimalType other = (AnimalType) object;
        if ((this.idAnimalType == null && other.idAnimalType != null) || (this.idAnimalType != null && !this.idAnimalType.equals(other.idAnimalType))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.AnimalType[ idAnimalType=" + idAnimalType + " ]";
    }
    
}
